<?php
	/**
	* Move product to another category
	* @author: trungdt
	* @since: Sep 26, 2011
	* @version: 1.0
	* 
	*  
	* Change logs
	* Sep 26, 2011 - trungdt - First create
	*/
	if (!defined('EXPONENT')) exit('');

	// Administrator access restrict
	if (exponent_users_isAdmin() || exponent_permissions_check(array('administrate', "configure", "create", "edit", "delete"),$loc))
	{
		$id="";
		if (isset($_POST['id']))
			$id=_ab_safe_html_string($_POST['id']);
		$cat_id="";
		if (isset($_POST['cat_id']))
			$cat_id=_ab_safe_html_string($_POST['cat_id']);
		// 
		$id=explode("|",urldecode($id));
		// build the SQL
		$id_list="";
		foreach ($id as $v)
			if (trim($v) != "")
				$id_list.=((trim($id_list)!="")?" OR ":"")." (id = {$v})";
		// cat the category
		$cat=productsmodule::__GetCategoryByID(intval($cat_id));
		//
		$sql="UPDATE {$db->prefix}productsmodule_products SET location_data = '{$cat->location_data}', cat_id = {$cat->id} WHERE {$id_list}";
		$db->sql($sql);
	}
	// call flag the ajax action
	exponent_theme_setFlagAjaxAction(true);
?>
